package com.windoent.yugioh.adapter.brvah;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.MyMsgBean;
import com.windoent.yugioh.utils.BaseMethod;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :
 */
public class MeMessageAdapter extends BaseQuickAdapter<MyMsgBean.DataBean.ResBean, BaseViewHolder> {

    public MeMessageAdapter() {
        super(R.layout.item_me_message, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MyMsgBean.DataBean.ResBean item) {
        helper.setText(R.id.tv_msg_numbers, BaseMethod.notNullDefaultValue(item.getCnt() + "", "0"))
                .setText(R.id.tv_system_notify, item.getName());
        MyMsgBean.DataBean.ResBean.FirstBean first = item.getFirst();
        if (first != null) {
            helper.setText(R.id.tv_system_time, BaseMethod.notNullDefaultValueNull(first.getView_time()))
                    .setText(R.id.tv_system_conten, BaseMethod.notNullDefaultValueNull(first.getName()));
        }
        LinearLayout llMsg = helper.getView(R.id.ll_msg);
        llMsg.setVisibility(item.getCnt() > 0 ? View.VISIBLE : View.GONE);
        ImageView view = helper.getView(R.id.iv_system_notification);
        String name = item.getName();
        if (BaseMethod.notNull(name) && name.contains("系统")) {
            view.setBackgroundResource(R.drawable.drawable_notification_system);
        } else {
            view.setBackgroundResource(R.drawable.drawable_notification_saishi);
        }
    }
}